/*     */ package com.zimbra.cs.service.admin;
/*     */ 
/*     */ import com.zimbra.common.account.Key.AccountBy;
/*     */ import com.zimbra.common.account.ZAttrProvisioning.AccountStatus;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*     */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*     */ import com.zimbra.cs.mailbox.Mailbox;
/*     */ import com.zimbra.cs.mailbox.MailboxManager;
/*     */ import com.zimbra.soap.JaxbUtil;
/*     */ import com.zimbra.soap.ZimbraSoapContext;
/*     */ import com.zimbra.soap.admin.message.DeleteAccountRequest;
/*     */ import com.zimbra.soap.admin.message.DeleteAccountResponse;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DeleteAccount
/*     */   extends AdminDocumentHandler
/*     */ {
/*  48 */   private static final String[] TARGET_ACCOUNT_PATH = { "id" };
/*     */   
/*  50 */   protected String[] getProxiedAccountPath() { return TARGET_ACCOUNT_PATH; }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean domainAuthSufficient(Map context)
/*     */   {
/*  57 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*     */   {
/*  65 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Element handle(Element request, Map<String, Object> context)
/*     */     throws ServiceException
/*     */   {
/*  73 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*  74 */     Provisioning prov = Provisioning.getInstance();
/*     */     
/*  76 */     DeleteAccountRequest req = (DeleteAccountRequest)JaxbUtil.elementToJaxb(request);
/*  77 */     String id = req.getId();
/*     */     
/*     */ 
/*  80 */     Account account = prov.get(Key.AccountBy.id, id, zsc.getAuthToken());
/*  81 */     defendAgainstAccountHarvesting(account, Key.AccountBy.id, id, zsc, Rights.Admin.R_deleteAccount);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  94 */     prov.modifyAccountStatus(account, ZAttrProvisioning.AccountStatus.maintenance.name());
/*     */     
/*  96 */     Mailbox mbox = Provisioning.onLocalServer(account) ? MailboxManager.getInstance().getMailboxByAccount(account, false) : null;
/*     */     
/*     */ 
/*  99 */     if (mbox != null) {
/* 100 */       mbox.deleteMailbox();
/*     */     }
/*     */     
/* 103 */     prov.deleteAccount(id);
/*     */     
/* 105 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "DeleteAccount", "name", account.getName(), "id", account.getId() }));
/*     */     
/*     */ 
/* 108 */     return zsc.jaxbToElement(new DeleteAccountResponse());
/*     */   }
/*     */   
/*     */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*     */   {
/* 113 */     relatedRights.add(Rights.Admin.R_deleteAccount);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/DeleteAccount.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */